package com.rakuten.api.mule.transformers;

import java.util.HashMap;
import java.util.Map;

import org.mule.api.MuleMessage;
import org.mule.api.transformer.TransformerException;
import org.mule.api.transport.PropertyScope;
import org.mule.transformer.AbstractMessageTransformer;
import org.mule.transformer.types.DataTypeFactory;

import com.rakuten.api.mule.model.Product;

public class BuildAddProductResponse  extends AbstractMessageTransformer{

    public BuildAddProductResponse() {
//	registerSourceType(DataTypeFactory.STRING);
//	setReturnDataType(DataTypeFactory.STRING);
    }

    public Object transformMessage(MuleMessage message, String outputEncoding) 
    		throws TransformerException {

    	try {
			Product product = message.getProperty("productInfo",
					PropertyScope.SESSION);
			//return product to payload
			message.setPayload(product);

    	} catch (Exception e) {                  
    		throw new TransformerException(this, e);
    	}
    	
    	return message;
    }
}
